package com.bit.deom.mapper;

import com.bit.deom.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserInfoMapper {

    @Select("select * from user_info")
    public List<UserInfo> getUserInfoList();

    @Select("select * from user_info where id = #{id}")
    public UserInfo selectByID(Integer id);

    @Insert("insert into user_info (id, user_name, password) values (#{id},#{userName},#{password})")
    public Integer insertUserInfo1(UserInfo userInfo);

    @Insert("insert into user_info (id, user_name, password) values (#{id},#{userName},#{password})")
    public Integer insertUserInfo2(UserInfo userInfo);

    @Select("select id," +
            " user_name as userName," +
            " password," +
            " delete_flag as deleteFlag," +
            " create_time as createTime," +
            " update_time as UpdateTime" +
            " from user_info")
    public List<UserInfo> getUserInfoListAS();

    @Select("select id, password, user_name, delete_flag, create_time, update_time from user_info")
    @Results(id = "userInfoMapper", value = {
            @Result(column = "user_name", property = "userName"),
            @Result(column = "delete_flag", property = "deleteFlag"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime")
    })
    public List<UserInfo> getUserInfoListResult();


    @Select("select id, password, user_name, delete_flag, create_time, update_time from user_info")
    @ResultMap("userInfoMapper")
    public List<UserInfo> getUserInfoListResult1();
}
